import { Pipe } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';

// tslint:disable-next-line:use-pipe-transform-interface
@Pipe({ name: 'safeHtml' })
export class SafeHtmlPipe {
  constructor(private sanitizer: DomSanitizer) { }

  public transform(html) {
    if (html.indexOf('blob:') >= 0) {
      return this.sanitizer.bypassSecurityTrustResourceUrl(html);
    } else {
      return html;
    }
  }
}
